package javaConcurrentDemo;
/**
 * 高级的使用枚举类
 * @author Administrator
 *
 */
public enum CountryEnum {
    ONE(1,"齐国"),TWO(2,"韩国"),THREE(3,"赵国"),FOUR(4,"楚国"),FIVE(5,"燕国"),SIX(6,"魏国");
	private Integer retCode;
	private String retValue;
	
	public Integer getRetCode() {
		return retCode;
	}

	public void setRetCode(Integer retCode) {
		this.retCode = retCode;
	}

	public String getRetValue() {
		return retValue;
	}

	public void setRetValue(String retValue) {
		this.retValue = retValue;
	}
    //构造方法
	CountryEnum(Integer retCode,String retValue){
		this.retCode = retCode;
		this.retValue = retValue;
	}
	
    //根据索引或者是key获取元素
	public static CountryEnum forEach_countryEnum(int index) {
		CountryEnum[] obj = CountryEnum.values();
		for(CountryEnum element:obj) {
			if(index==element.getRetCode()) {
				return element;
			}
		}
	 
		return null;
	}
	
}
